<template>
	<view class="container">
		<view class="content">
			<view class="item">
				<view class="label">订单ID:</view>
				<view class="value">{{ steps.orderId }}</view>
			</view>
			<view class="item">
				<view class="label">物流单号:</view>
				<view class="value">{{ steps.id }}</view>
			</view>
			<view class="item">
				<view class="label">物流公司:</view>
				<view class="value" v-if="steps.company">{{ steps.company.name }}</view>
			</view>
			<view class="item">
				<view class="label">送件人:</view>
				<view class="value" v-if="steps.postman">{{ steps.postman.name }}</view>
			</view>
			<view class="item">
				<view class="label">物流状态:</view>
				<view class="value" style="color:blue">{{ getStatusText(steps.status-0) }}</view>
			</view>
			<view class="item">
				<view class="label">发货地址:</view>
				<view class="value">{{ steps.shippingAddress }}</view>
			</view>
			<view class="item">
				<view class="label">收货地址:</view>
				<view class="value">{{ steps.deliveryAddress }}</view>
			</view>
			<view class="item">
				<view class="label">详细地址:</view>
				<view class="value">{{ steps.address }}</view>
			</view>
			<view class="item">
				<view class="label">发货时间:</view>
				<view class="value">{{ steps.deliveryTime }}</view>
			</view>
			<view class="item">
				<view class="label">预计到达时间:</view>
				<view class="value">{{steps.estimatedTime }}</view>
			</view>
			<view class="checkInfo"><button @click="watchInfo">详细信息</button></view>
		</view>

	</view>
</template>
<script>
	import {
		findLogisticsById
	} from "../../../api/logistics/logistics";
	export default {
		data() {
			return {
				logsNumber: 1,
				steps: []
			}
		},
		async created() {
			
			
			this.getLogsNumber()
			let data = await findLogisticsById(this.logsNumber)
			this.steps = data.data
			console.info(this.steps)
		},

		methods: {
			getLogsNumber() {
				const pages = getCurrentPages();
				    const currentPage = pages[pages.length - 1];
				    const options = currentPage.options;
				    const data = JSON.parse(options.data);
				this.logsNumber = data
			},
			watchInfo() {
				this.$tab.navigateTo('/pages/mine/logistics/info?data=' + JSON.stringify(this.steps));
			},
			getStatusText(status) {
				switch (status) {
					case 0:
						return "下单";
					case 1:
						return "已发货";
					case 2:
						return "已揽件";
					case 3:
						return "运输中";
					case 4:
						return "派送中";
					case 5:
						return "待取件";
					case 6:
						return "已签收";
					default:
						return "";
				}
			},
		},
	}
</script>
<style>
	.checkInfo {
		background-color: #f3914b;
		text-align: center;
	}

	.container {
		background-color: #f2f2f2;
		padding: 20rpx;
		height: 100vh;
	}

	.title {
		font-size: 24rpx;
		text-align: center;
		margin-top: 20rpx;
		margin-bottom: 30rpx;
		color: #333;
	}

	.content {
		background-color: #fff;
		padding: 20rpx;
		border-radius: 10rpx;
		box-shadow: 0 2rpx 5rpx rgba(0, 0, 0, 0.1);
	}

	.item {
		margin-bottom: 20rpx;
	}

	.label {
		font-weight: bold;
		margin-right: 10rpx;
		color: #666;
		display: inline-block;
	}

	.value {
		color: #333;
		display: inline-block;
	}
</style>